package com.ldy.demo7;

import org.apache.commons.lang3.CharSequenceUtils;
import org.apache.commons.lang3.CharSetUtils;
import org.apache.commons.lang3.CharUtils;
import org.junit.Test;

import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Iterator;
import java.util.Stack;

public class XMLHandlerTest {
    private static final String URL = "https://makeabooking.flyscoot.com/";

    @Test
    public void testRetrieveSchedule() {
        try {
             System.setProperty("https.protocols", "TLSv1.1");
            HttpURLConnection connection = (HttpURLConnection) new URL(URL).openConnection();
            connection.setRequestMethod("HEAD");
            int responseCode = connection.getResponseCode();
            System.out.println(responseCode);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testStringToUnicode() throws Exception{
        String 张三 = "张三";
        System.out.println(张三);
    }

    @Test
    public void testMutilFor() throws InterruptedException {
        for (int i=0; i< 10 ;i ++) {
            int count = 0;
            while (true) {
                System.out.println(i);
                Thread.sleep(1000);
                if (count++ == 3) {
                    break;
                }
            }
            System.out.println(count);
        }
    }

    @Test
    public void testStack() {
        Stack<String> stack = new Stack();
        stack.push("aaa");
        stack.push("bbb");
        Iterator<String> iterator = stack.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
        System.out.println();
        System.out.println(stack.peek());
        stack.pop();
        System.out.println(stack.peek());
        System.out.println(stack.empty());
        stack.pop();
        System.out.println(stack.empty());
    }

    @Test
    public void testStringBuildDelete() {
        StringBuilder sb = new StringBuilder("CEBC");
        sb.delete(sb.length() - 3, sb.length());
        System.out.println(sb.toString());
    }

    @Test
    public void test1() {
        String s = "12";
        boolean matches = s.matches("\\d+");
        System.out.println(matches);
    }

}